package com.ly.spring.mapper;

import com.ly.spring.biz.UserBiz;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/11/2
 * Email haijunzhou@hnit.edu.cn
 */
@Repository  // id 默认类名首字母小写 userMapper
@Lazy
@Scope("prototype")
@Primary
@Data
public class UserMapper {

    String myName = "张三";

//    @Autowired
//    private UserBiz userBiz;

    public UserMapper() {
        System.out.println("======UserMapper.UserMapper=======" + myName);
    }

    // 构造函数之后执行的方法
    @PostConstruct
    public void init(){
        // 构造函数的java对象的初始化, jvm的初始化
        //  @PostConstruct Spring的初始化,
        //  会在内部属性完成 Spring 注入之后再执行
        System.out.println("======UserMapper.init=======" + myName);
    }

    @PreDestroy
    public void finish(){
        System.out.println("======UserMapper.finish=======" + myName);
    }


    public void login(String name, String pwd){
        System.out.println("===========登录==========");
    }

    public String reg(){
        System.out.println("===========注册==========");
        return "注册成功!";
    }

    public void query(){
        Object o = 100;
        // Integer i = 200;
        String s = (String) o;
        System.out.println("s = " + s);
        System.out.println("===========查询==========");
    }

}
